using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[ExecuteInEditMode]
public class RenderObjectByCamera : MonoBehaviour
{
    public Mesh mainMesh;
    public Material mat;
    public float distance = 20;
    public Quaternion rot = Quaternion.Euler(0,180,0);
    public Camera target;
 
 

    private void OnEnable()
    {
    
 
    
    }
    public Vector3 debuPos;
     
    void OnRenderObject()
    {
        if (null == mat)
        {
            //mat = new Material(Shader.Find("Tools/VertexColorHelper"));
            mat = new Material(Shader.Find("Tools/VertexColorHelper"));
        }

        if (Camera.current == target)
        {
            mat.SetPass(0);
            Graphics.DrawMeshNow(mainMesh, new Vector3(0f, 0f, distance), rot);
        }
           
    }
}
